package com.kurancy.domain;

import com.kurancy.domain.enums.KurancyStatus;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Enumerated;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
import org.springframework.roo.addon.tostring.RooToString;

@RooJavaBean
@RooToString
@RooJpaActiveRecord(finders = { "findKurancyCreatedsByCreatedByEquals", "findKurancyCreatedsByKurancyTokenEquals", "findKurancyCreatedsByGrantedByEquals", "findKurancyCreatedsByPaypalPayKeyEquals" })
public class KurancyCreated {

    @NotNull
    @Value("20.00")
    @Min(1L)
    @Max(1000L)
    private BigDecimal amount;

    @Column(unique = true)
    private String kurancyToken;

    private String createdBy;

    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(pattern = "MM/dd/yyyy hh:mm:ss a")
    private Date createdOn;

    private String claimedBy;

    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(pattern = "MM/dd/yyyy hh:mm:ss a")
    private Date claimedOn;

    @Enumerated
    private KurancyStatus status = KurancyStatus.ACTIVE;

    @NotNull
    @OneToMany(cascade = CascadeType.ALL)
    private Set<KurancyHistory> kuruancyHistories = new HashSet<KurancyHistory>();

    private String paypalPayKey;
}
